package com.xsomnus.open.imv2.foo.client.console;

import com.xsomnus.open.imv2.protocol.request.CreateGroupRequestPacket;
import io.netty.channel.Channel;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author @xsomnus666_xiawenye★
 * @since 2019/4/26 0026 9:47
 * 当你发现自己的才华撑不起野心时，就请安静下来学习吧
 */
public class CreateGroupConsoleCommand implements ConsoleCommand {
    private static final String USER_ID_SPLITER = ",";

    @Override
    public void exec(Scanner scanner, Channel channel) {
        CreateGroupRequestPacket requestPacket = new CreateGroupRequestPacket();
        System.out.print("[拉人群聊]输入userId列表, userId之间用英文逗号隔开:");
        String userIds = scanner.next();
        requestPacket.setUserIdList(Arrays.asList(userIds.split(USER_ID_SPLITER)));
        System.out.println("createGroupRequest: " + requestPacket);
        channel.writeAndFlush(requestPacket);
    }
}
